package com.dubbo;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class AA {


    public static String getLocalMac(InetAddress ia) throws SocketException {
        //获取网卡，获取地址
        byte[] mac = NetworkInterface.getByInetAddress(ia).getHardwareAddress();
        //System.out.println("mac数组长度："+mac.length);
        StringBuffer sb = new StringBuffer("");
        for(int i=0; i<mac.length; i++) {
            if(i!=0) {
                sb.append("-");
            }
            //字节转换为整数
            int temp = mac[i]&0xff;
            String str = Integer.toHexString(temp);
            //System.out.println("每8位:"+str);
            if(str.length()==1) {
                sb.append("0"+str);
            }else {
                sb.append(str);
            }
        }

        String myMac=sb.toString().toUpperCase();
        //System.out.println("本机MAC地址:"+myMac);

        return myMac;

    }

    public static void main(String[] args) throws UnknownHostException {

//        //得到IP，输出PC-201309011313/122.206.73.83
//        InetAddress ia = InetAddress.getLocalHost();
//        String ip=ia.toString().split("/")[1];
//
//        System.out.println(ia);
//        System.out.println("IP:"+ip);
//
//        try {
//            getLocalMac(ia);
//        } catch (SocketException e) {
//            e.printStackTrace();}
        Map<String, Object> map1 = new HashMap<>();
        map1.put("a", "1");
        map1.put("b", "2");
        map1.put("c", "3");
        Map<String, Object> map2 = new HashMap<>();
        map2.put("a", "11");
        map2.put("b", "22");
        map2.put("c", "33");
        Map<String, Object> map21 = new HashMap<>();
        map21.put("a", "11");
        map21.put("b", "22");
        map21.put("c", "33");
//        map21.put("d", "44");
        Map<String, Object> map3 = new HashMap<>();
        map3.put("a", "111");
        map3.put("b", "222");
        map3.put("c", "333");
        List<Map<String, Object>> list1 = new ArrayList<>();
        list1.add(map1);
        list1.add(map2);
        List<Map<String, Object>> list2 = new ArrayList<>();
        list2.add(map21);
        list2.add(map3);
        List<Map<String, Object>> diff1 = new ArrayList<>(list1);
        diff1.removeAll(list2);
        System.out.println(diff1);
        List<Map<String, Object>> diff2 = new ArrayList<>(list2);
        diff2.removeAll(list1);
        System.out.println(diff2);
    }

}

